#include"process.h"
double gtotal = 1024.0;//1024M
double speed = 1.0;//设置浮动区间使用种子函数

double speedFloat(double speed,double range)//[1,0,5.3]
{
  int int_range = (int)range;
  return speed + rand()%int_range + (range - int_range);//记得加上小数部分
}

void DownLoad(int total,callback_t cd)
{
  srand(time(NULL));
  double curr = 0;
  while(curr <= total)
  {
    curr += speedFloat(speed,20.3);
    cd(curr,total);//这里千万不能传引用，否则会造成死循环
    usleep(30000);
  }
}

int main()
{
  
  DownLoad(gtotal,FlushProcess);

  //process();
  return 0;
}
